package com.gw.vip.center.service.dao_service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gw.vip.center.dao.SysArgMapper;
import com.gw.vip.center.po.SysArg;
import com.gw.vip.common.exception.ExceptionEnums;
import com.gw.vip.common.exception.ServiceException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * @author GW
 * @description
 * @since 2022-04-16
 */
@Service
@Slf4j
public class SysArgService extends ServiceImpl<SysArgMapper, SysArg> {
    public String getString(String id){
        SysArg sysArg = this.getById(id);
        if (sysArg==null){
            log.error("配置【{}】不存在。", id);
            throw new ServiceException(ExceptionEnums.ERROR_SETTING);
        }
        return sysArg.getArgValue();
    }

    public Integer getInteger(String id){
        String value = this.getString(id);
        return Integer.parseInt(value);
    }
}
